import React,{Component} from 'react';
import { Button, View, Text, StatusBar } from 'react-native';
import Home from './Home';

export default class DetailsScreen extends Component {
    back =(state,goBack)=>{ //把属性传递过来，然后进行使用
        state.params.callback('this is back data') //回调传值
        goBack() //点击POP上一个页面得方法
    }
    render() {
        // alert(this.props.navigation.navigate);
        const { params } = this.props.navigation.state;
        const  {navigate,goBack,state} = this.props.navigation;
        const id = params ? params.id : null;
        return (
            <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
                {/*<StatusBar hidden={false} translucent={true} barStyle={'dark-content'} backgroundColor={'red'} />*/}
                <Text>{id}</Text>
                <Text>Details Screen</Text>
                <Home navigate={this.props.navigation.navigate}/>
                <Button
                    onPress={() => this.back(state,goBack)}
                    title="Back"
                />
            </View>
        );
    }
}